#include <iostream>
#include <sqlite3.h>

int main() {
    sqlite3 *db;
    char *zErrMsg = 0;
    int rc;

    rc = sqlite3_open("test.db", &db);

    if (rc) {
        std::cerr << "Can't open database: " << sqlite3_errmsg(db) << std::endl;
        return rc;
    } else {
        std::cout << "Opened database successfully" << std::endl;
    }

    const char *sql = "CREATE TABLE COMPANY(" \
                      "ID INT PRIMARY KEY     NOT NULL," \
                      "NAME           TEXT    NOT NULL," \
                      "AGE            INT     NOT NULL," \
                      "ADDRESS        CHAR(50)," \
                      "SALARY         REAL );";
    
    rc = sqlite3_exec(db, sql, nullptr, 0, &zErrMsg);

    if (rc != SQLITE_OK) {
        std::cerr << "SQL error: " << zErrMsg << std::endl;
        sqlite3_free(zErrMsg);
    } else {
        std::cout << "Table created successfully" << std::endl;
    }

    sqlite3_close(db);
    return 0;
}
